﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SaleManagement.Web.App_Code;
using SaleManagement.Services;

namespace SaleManagement.Web.Pages
{
  public partial class PaymentReport : BasePage
  {


    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack && !IsCallback)
      {
        deFromDate.Date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
        deToDate.Date = DateTime.Now;
      }
    }

    protected void gvPurchase_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
    {
      LoadList();
    }

    private void LoadList()
    {
      DateTime fromDate = deFromDate.Date;
      DateTime toDate = deToDate.Date;

      gvPurchase.DataSource = new PaymentService().GetPaymentReport(fromDate, toDate);
      gvPurchase.DataBind();
    }

    protected void btnExport_Click(object sender, EventArgs e)
    {
      LoadList();
      this.gvPurchaseExport.FileName = string.Format("Tien_hang_{0}", DateTime.Now.ToString("ddMMyyyy"));
      this.gvPurchaseExport.WriteXlsToResponse();
    }

    protected void btnPdfExport_Click(object sender, EventArgs e)
    {

    }
  }
}
